package com.jeecms.wicool.manager.image.impl;

import com.jeecms.wicool.dao.image.ShareImageEntityDao;
import com.jeecms.wicool.entity.image.ShareImageEntity;
import com.jeecms.wicool.manager.image.ShareImageEntityManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created by cuiyanlei on 15/6/7.
 */
@Service
@Transactional
public class ShareImageEntityManagerImpl implements ShareImageEntityManager {
    @Override
    public ShareImageEntity deleteById(Integer id) {
        return dao.deleteById(id);
    }

    @Override
    public ShareImageEntity save(ShareImageEntity bean) {
        return dao.save(bean);
    }

    @Override
    public List<ShareImageEntity> getAll(Integer foreginKey, int type) {
        return dao.getAll(foreginKey, type);
    }

    @Override
    public List<ShareImageEntity> deleteByForeginKey(int foreginKey, int type) {
        List<ShareImageEntity> entities = getAll(foreginKey, type);
        for (ShareImageEntity entity : entities) {
            deleteById(entity.getId());
        }
        return entities;
    }

    @Autowired
    private ShareImageEntityDao dao;
}
